package com.chen.script.controller;

import com.chen.base.utils.AnnotationRouteUtil;
import com.chen.root.base.R;
import com.chen.script.annotation.Job;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 陈锦龙
 * @Date: 2025/3/20 15:27
 */
@RestController
@RequestMapping("/job")
@Api(value = "job", tags = "定时任务API")
public class JobController {

    @GetMapping
    @ApiOperation(value = "根据key执行一次",notes = "根据key执行一次")
    public R<String> job(String key) throws Exception {
        AnnotationRouteUtil.route(Job.class, Job::value, key,
                (bean, method, job) -> method.invoke(bean, new Object[method.getParameterCount()])
        );
        return R.ok(null, "OK");
    }


}
